#!/usr/bin/python3

import pymysql as mysqldb

db = mysqldb.connect(user="root", passwd="111111", host="localhost")
 db.autocommit(True)
cur = db.cursor()

c_db = "create database sanle_1"
cur.execute(c_db)

cur.execute("use sanle_1")
c_tb = "create table student(id int NOT NULL,name varchar(10),age int,phone_num decimal(20),address varchar(60),major varchar(20),primary key(id))"
cur.execute(c_tb)

i_date_1="insert into student(id,name,age,phone_num,address,major) values (1,'cali',33,18907495769,'yongzhou','macth')"

i_date_2="insert into student(id,name,age,phone_num,address,major) values (2,'cheng',13,18907435769,'yongzhou','macth')"

i_date_3="insert into student(id,name,age,phone_num,address,major) values (3,'kong',31,18907495969,'yongzhou','macth')"
cur.execute(i_date_1)
cur.execute(i_date_2)
cur.execute(i_date_3)
cur.execute('select id,name,age,phone_num,address,major from student')
datas=cur.fetchall()

for i in datas:
    print(i)

db.close()
